#define _CRT_SECURE_NO_WARNINGS
#include "Flowfield.h"
Flowfield::Flowfield() {
	gVxInlet = 0.0;
	gVxOutlet = 0.0;
	xInlet = 0.0;
	xOutlet = 0.0;
	linearK = 0.0;
	linearb = 0.0;
}

Flowfield::Flowfield(const shared_ptr<ModelSettings> modelSetting1, const shared_ptr<CaseSettings> caseSetting1) {
	gVxInlet = (*modelSetting1).gVxStart;
	gVxOutlet = (*modelSetting1).gVxEnd;

	double p0_x = (*caseSetting1).coordinateVertex0[0];
	double p1_x = (*caseSetting1).coordinateVertex1[0];
	double p2_x = (*caseSetting1).coordinateVertex2[0];
	double p3_x = (*caseSetting1).coordinateVertex3[0];
	assert(p0_x == p3_x && p1_x == p2_x && "X coordinate of The domain geometry is out of the scenarios considered in this study");
	xInlet = p0_x;
	xOutlet = p1_x;
	linearK = (gVxOutlet - gVxInlet) / (xOutlet - xInlet);
	linearb = gVxInlet - linearK * xInlet;
}
double Flowfield::GetGasVelocityX(double xCoordinate)
{
	double vel;
	vel = linearK * xCoordinate + linearb;
	return vel;
}

vector<double> Flowfield::GetGasVelocityX(vector<double> xCoordinate)
{
	vector<double> vel(xCoordinate.size(), 0.0);
	for (int i = 0; i < xCoordinate.size(); i++)
	{
		vel[i] = linearK * xCoordinate[i] + linearb;
	}
	return vel;
}
